package com.gagakuai.engine.service;

import com.gagakuai.engine.runtime.ProcessInstance;

import java.util.List;
import java.util.Map;

/*
 * @program: common-starters
 * @description: 流程运行服务
 * @author: houhong
 * @create: 2023-01-02 14:32
 */
public interface RuntimeService {

    /*
     * 使用给定key 在最新版本的流程定义中启动一个新的流程实例
     */
    ProcessInstance startProcessInstanceBykey(String processDefinitionKey);

    ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey);

    ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables);

    ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey, Map<String, Object> variables);

    ProcessInstance startProcessInstanceByKeyAndTenantId(String processDefinitionKey, String tenantId);


    ProcessInstance startProcessInstanceById(String processDefinitionId);

    ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey);

    ProcessInstance startProcessInstanceById(String processDefinitionId, Map<String, Object> variables);

    ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey, Map<String, Object> variables);

    /*
     * 以消息的形式开启一个流程实列
     */
    ProcessInstance startProcessInstanceByMessage(String messageName);


    ProcessInstance startProcessInstanceByMessage(String messageName, String businessKey);

    ProcessInstance startProcessInstanceByMessageAndTenantId(String messageName, String businessKey, String tenantId);

    ProcessInstance startProcessInstanceByMessage(String messageName, Map<String, Object> processVariables);


    /*
     * 删除流程实列
     */
    void deleteProcessInstance(String processInstanceId, String deleteReason);

    /*
     * 查找在活动中等待的所有执行的活动 ID。
     * 这是一个列表，因为单个活动可以多次激活。
     */
    List<String> getActiveActivityIds(String executionId);

    /*
     * 将外部触发器发送到在内部等待的活动实例
     * 给定的执行。
     */
    void signal(String executionId);

    void signal(String executionId, Map<String, Object> processVariables);

}